package com.supermap.desktop.develop.workspacemigration.migration;

import com.supermap.data.EngineType;
import com.supermap.desktop.develop.workspacemigration.internalhelpers.InternalHelper;

import javax.swing.*;

public class WorkspaceMigrationFactory {

    protected WorkspaceMigrationFactory() {
    }

    public static WorkspaceMigration createWorkspaceMigration(String srcIP, String srcPort, String srcDatabaseName,
                                                              String srcUserName, String srcPassword, EngineType srcEngineType,
                                                              String srcWorkspaceName, String tarIP, String tarPort,
                                                              String tarDatabaseName, String tarUserName, String tarPassword,
                                                              EngineType tarEngineType, boolean isBatchMigration) {
        SwingUtilities.invokeLater(InternalHelper::clearMigrationTempResources);
        WorkspaceMigration workspaceMigration = null;

        if ((srcEngineType == EngineType.POSTGRESQL || srcEngineType == EngineType.PGGIS) && tarEngineType == EngineType.DM) {
            workspaceMigration = new PG2DMDBWorkspaceMigration(srcIP, srcPort,
                    srcDatabaseName, srcUserName, srcPassword, srcEngineType, srcWorkspaceName, tarIP, tarPort,
                    tarDatabaseName, tarUserName, tarPassword, tarEngineType, isBatchMigration);
        }

        return workspaceMigration;
    }
}
